import rsaEncrypt from 'encryptlong';

/**
 * rsa 加密数据
 * @param publicKey
 * @param obj
 * @returns {*}
 */
export const encrypt = (publicKey, obj) => {
    const encryptor = new rsaEncrypt();
    encryptor.setPublicKey(publicKey)
    const result = encryptor.encryptLong(obj)
    return result;
};

/**
 * rsa 解密数据
 * @param privateKey
 * @param obj
 * @returns {*}
 */
export const decrypt = (privateKey, obj) => {
    const decryptor = new rsaEncrypt();
    decryptor.setPrivateKey(privateKey);
    const result = decryptor.decryptLong(obj);
    return result;
};

export default {
    encrypt,
    decrypt,
};

